
// 232.用栈实现队列
class MyQueue {
    // 用两个栈来实现
    // 一个专门用来入栈,一个专门用来出栈
    stack<int> stph;
    stack<int> stpo;
public:
    MyQueue() {}
    
    void push(int x) {
        stph.push(x);
    }
    
    int pop() {
        int ret = peek();  
        stpo.pop();
        return ret;
    }
    
    int peek() {
        if(stpo.empty())
        {
            while(stph.size())
            {
                stpo.push(stph.top());
                stph.pop();
            }
        }
        return stpo.top();
    }
    
    bool empty() {
        return stph.empty()&&stpo.empty();
    }
};

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue* obj = new MyQueue();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->peek();
 * bool param_4 = obj->empty();
 */